package zjitc.service.impl;

import zjitc.dao.TestDao;
import zjitc.dao.impl.TestDaoImpl;
import zjitc.domain.Test;
import zjitc.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private TestDao dao = new TestDaoImpl();
    @Override
    public List<Test> findAll() {
        //调用Dao完成查询
        return dao.findAll();
    }
    public Test login(String username,String password){
        List<Test> list = dao.findAll();
        for (Test test : list) {
            if(username.equals(test.getUsername())&&password.equals(test.getPassword())){
                return test;
            }
        }
        return null;
    }

    @Override
    public void addUser(Test user) {
        dao.addUser(user);
    }

    @Override
    public void deleteUser(String name) {
        dao.deleteUser(name);
    }

    @Override
    public void updateUser(Test user,String checkName) {
        dao.updateUser(user,checkName);
    }

    @Override
    public Test findUserByName(String name) {
        return dao.findByName(name);
    }

    @Override
    public void registerUser(Test user) {
        dao.registerUser(user);
    }

}
